package com.ahcloud.edas.gatewaylog.biz.infrastructure.configuration;

import com.ahcloud.edas.gatewaylog.biz.application.service.GatewayLogService;
import com.ahcloud.edas.gatewaylog.biz.domain.log.dto.GatewayRequestLogDTO;
import com.ahcloud.edas.gatewaylog.biz.infrastructure.log.DbLogCollector;
import com.ahcloud.edas.gatewaylog.biz.infrastructure.log.LogCollector;
import com.ahcloud.edas.gatewaylog.biz.infrastructure.log.client.DbLogCollectClient;
import com.ahcloud.edas.gatewaylog.biz.infrastructure.log.client.LogConsumeClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: ahcloud-operatelog
 * @description:
 * @author: YuKai Fan
 * @create: 2024/5/26 22:20
 **/
@Configuration
@EnableConfigurationProperties(OperateLogProperties.class)
public class OperateLogConfiguration {

    @Bean
    public DbLogCollectClient logCollectClient(GatewayLogService gatewayLogService) {
        return new DbLogCollectClient(gatewayLogService);
    }

    @Bean
    public LogCollector<GatewayRequestLogDTO> logCollector(OperateLogProperties properties, DbLogCollectClient logCollectClient) {
        return new DbLogCollector(properties, logCollectClient);
    }
}
